home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / Game.EXE_01_2001.iso / demos / Blade of Darkness / data1.cab / Program_Executable_Files / Lib / GameText.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-11-16  |  5.6 KB  |  148 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Scorer
  5. import Bladex
  6. import os
  7. import Interpolator
  8. import string
  9. Textos = { }
  10. MapList = { }
  11. ComboNames = {
  12.     'Knight_N': { },
  13.     'Barbarian_N': { },
  14.     'Amazon_N': { },
  15.     'Dwarf_N': { },
  16.     'Default': { } }
  17. FADE_TIME = 1.0
  18. current_language = None
  19.  
  20. def SetLanguage(lang):
  21.     global current_language
  22.     if lang != current_language:
  23.         current_language = lang
  24.         print 'Setting language', lang
  25.         l_path = '../../Data/Text/' + lang
  26.         if not os.path.exists(l_path):
  27.             return None
  28.         
  29.         files = os.listdir(l_path)
  30.         for i in files:
  31.             file = l_path + '/' + str(i)
  32.         
  33.     
  34.  
  35.  
  36. def MapDescriptor(map):
  37.     if MapList.has_key(string.upper(map)):
  38.         return MapList[string.upper(map)]
  39.     else:
  40.         return map
  41.  
  42.  
  43. class FadeText(Interpolator.LinearInt):
  44.     
  45.     def __init__(self, init_val, end_val):
  46.         Interpolator.LinearInt.__init__(self, init_val, end_val)
  47.         self.Interpolator = Interpolator.Interp('FadeText')
  48.         time = Bladex.GetTime()
  49.         self.Interpolator.AddAction(time, time + FADE_TIME, self)
  50.         self.end_val = end_val
  51.  
  52.     
  53.     def Execute(self, value):
  54.         ret = Interpolator.LinearInt.Execute(self, value)
  55.         Scorer.wGameText.SetAlpha(ret)
  56.  
  57.     
  58.     def EndExecute(self):
  59.         self.Interpolator.Kill()
  60.         Scorer.wGameText.SetAlpha(self.end_val)
  61.         if self.end_val == 0:
  62.             Scorer.wGameText.SetText('')
  63.         
  64.  
  65.  
  66.  
  67. def ClearText():
  68.     FadeText(1, 0)
  69.  
  70.  
  71. def AbortText():
  72.     Bladex.RemoveScheduledFunc('ClearText')
  73.     Bladex.RemoveScheduledFunc('NextText')
  74.     Scorer.wGameText.SetAlpha(0)
  75.     Scorer.wGameText.SetText('')
  76.  
  77.  
  78. def WriteTextAux(txt, duration, init_r, init_g, init_b, next_text, ypos = None):
  79.     Scorer.wGameText.SetColor(init_r, init_g, init_b)
  80.     Scorer.wGameText.SetText(txt)
  81.     if ypos != None:
  82.         Scorer.wFrame.MoveWidgetTo('GameTextWidget', 0.5, ypos)
  83.     else:
  84.         Scorer.wFrame.MoveWidgetTo('GameTextWidget', 0.5, 27)
  85.     Scorer.wFrame.RecalcLayout()
  86.     FadeText(0, 1)
  87.     now = Bladex.GetTime()
  88.     if next_text == []:
  89.         Bladex.AddScheduledFunc(now + duration, ClearText, (), 'ClearText')
  90.     else:
  91.         Bladex.AddScheduledFunc(now + duration, ClearText, (), 'ClearText')
  92.         Bladex.AddScheduledFunc(now + duration + FADE_TIME, WriteTextAux, (next_text[0], duration, init_r, init_g, init_b, next_text[1:], ypos), 'NextText')
  93.  
  94.  
  95. def WriteText(txt_id, ypos = None):
  96.     
  97.     try:
  98.         _txt = Textos[txt_id]
  99.         txt = _txt[4]
  100.     except:
  101.         print "Error: can't print message", txt_id
  102.         return None
  103.  
  104.     nLines = string.count(txt, '\n') + 1
  105.     nParagraphs = nLines / 5 + 1
  106.     paragraphs = []
  107.     if nParagraphs > 1:
  108.         l = string.split(txt, '\n')
  109.         counter = 0
  110.         t_str = ''
  111.         for i in l:
  112.             t_str = t_str + i + '\n'
  113.             counter = counter + 1
  114.         
  115.         if t_str != '':
  116.             paragraphs.append(t_str)
  117.         
  118.         WriteTextAux(paragraphs[0], _txt[0], _txt[1], _txt[2], _txt[3], paragraphs[1:], ypos)
  119.     else:
  120.         WriteTextAux(txt, _txt[0], _txt[1], _txt[2], _txt[3], [], ypos)
  121.  
  122.  
  123. def ShowMessage(message = '', r = 255, g = 255, b = 255):
  124.     Scorer.wGameText.SetText(message)
  125.     Scorer.wGameText.SetAlpha(1.0)
  126.     Scorer.wGameText.SetColor(r, g, b)
  127.     Scorer.wFrame.RecalcLayout()
  128.  
  129.  
  130. def HideMessage():
  131.     ShowMessage()
  132.  
  133.  
  134. def GetComboName(EntityName, ComboId):
  135.     kindName = Bladex.GetEntity(EntityName).Kind
  136.     
  137.     try:
  138.         return ComboNames[kindName][ComboId]
  139.     except:
  140.         
  141.         try:
  142.             return ComboNames['Default'][ComboId]
  143.         except:
  144.             return None
  145.  
  146.  
  147.  
  148.